<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- STYLESHEETS -->
    <!--[if lt IE 9]>
    <script src="../../js/flot/excanvas.min.js"></script>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
    <link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
    <link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
    <link rel="stylesheet" type="text/css" href="../../css/responsive.css">
    <link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- SELECT2 -->
    <link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
    <!-- file-input -->
    <link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
    <!-- UNIFORM -->
    <link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
    <!-- datatable -->
    <link rel="stylesheet" href="../../js/datatables/datatable.css">
    <link rel="stylesheet" href="../../js/datepicker/datepicker.css">
    <!-- JQUERY -->
    <script src="../../js/jquery/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>
    <script src="../../js/common.js"></script>
</head>

<body>
    <header class="navbar clearfix" id="header">
    </header>

    <!-- PAGE -->
    <section id="page">
        <!-- SIDEBAR -->
        <div id="sidebar" class="sidebar">
            <div class="sidebar-menu nav-collapse">

                <!-- SIDEBAR MENU -->
                <ul>

                </ul>
                <!-- /SIDEBAR MENU -->
            </div>

        </div>
        <!-- /SIDEBAR -->
        <div id="main-content">

            <!--- 归档弹窗-->
            <div class="modal fade" id="archivedBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">归档</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>合同编号：</label>
                                <div class="col-md-8">
                                    <input type="text" class="form-control" name="contractCode" placeholder="请输入合同编号"
                                        maxlength="20" />
                                    <input type="hidden" name="id" />
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-success bt-save">保存</button>
                        </div>
                    </div>
                </div>
            </div>

            <!--- 备注弹窗-->
            <div class="modal fade" id="remarkBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">添加备注</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>备注：</label>
                                <div class="col-md-8">
                                    <textarea name="remark" placeholder="请输入备注" style="width: 300px;height: 90px"></textarea>
                                    <input type="hidden" name="id" />
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-success bt-save">保存</button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 作废弹窗-->
            <div class="modal fade" id="cancelBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">作废</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>作废原因：</label>
                                <div class="col-md-8">
                                    <textarea name="cancelReason" placeholder="请输入作废原因" style="width: 300px;height: 90px"></textarea>
                                    <input type="hidden" name="id" />
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-success bt-save">保存</button>
                        </div>
                    </div>
                </div>
            </div>


            <div class="container">
                <div class="row">
                    <div id="content" class="col-lg-12">
                        <!-- SAMPLE BOX CONFIGURATION MODAL FORM-->
                        <div class="modal fade" id="box-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                            aria-hidden="true">
                            <div class="modal-dialog">
                                <form id="form_focus">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title">上传合同扫描件</h4>
                                        </div>
                                        <div class="modal-body">
                                            <div class="form-group  mrg-bt10">
                                                <input type="hidden" name="id" />
                                                <label class="control-label col-md-3" style="line-height:34px;">合同编号：</label>
                                                <div class="col-md-6 contractCode">


                                                </div>
                                            </div>
                                            <div class="form-group  mrg-bt10" style="height: 100px">
                                                <label class="control-label col-md-3" style="line-height:34px;"><span
                                                        class="required">*</span>上传文件：</label>
                                                <form>
                                                    <div class="col-md-8">
                                                        <div hidden-image></div>
                                                        <div class="fileinput fileinput-new" data-provides="fileinput">

                                                            <div style="float:left; margin-left:5px;" class="addnewimg"
                                                                id="f_span">
                                                                <span class="btn btn-default btn-file" id="fir">
                                                                    <span class="fileinput-new" id="two">上传图片</span>
                                                                    <span class="fileinput-exists">Change</span>
                                                                    <input type="file" name="uploadFile" upload-file="imageUrlProduct">
                                                                </span>
                                                                <div class="progress progress-striped active" role="progressbar"
                                                                    aria-valuemin="0" aria-valuemax="100" style=" margin-bottom: 0px;margin-top:10px;">
                                                                    <div class="progress-bar progress-bar-success"
                                                                        style="width:0%;"></div>
                                                                </div>
                                                            </div>

                                                        </div>


                                                    </div>
                                                </form>

                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

                                            </div>

                                        </div>

                                    </div>
                                </form>

                            </div>
                        </div>
                        <!-- /SAMPLE BOX CONFIGURATION MODAL FORM-->

                        <!-- PAGE HEADER-->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="page-header">
                                    <!-- STYLER -->

                                    <!-- /STYLER -->
                                    <!-- BREADCRUMBS -->
                                    <ul class="breadcrumb">
                                        <li>
                                            <i class="fa fa-home"></i>
                                            <a href="index.html">首页</a>
                                        </li>
                                        <li>
                                            <a href="#">营销管理</a>
                                        </li>
                                        <li>优惠劵</li>
                                    </ul>
                                    <!-- /BREADCRUMBS -->

                                </div>
                            </div>
                        </div>
                        <!-- /PAGE HEADER -->
                        <!-- FORMS QUERY-->
                        <div class="row">
                            <div class="col-md-12">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="box border primary">
                                            <div class="box-title">
                                                <h4><i class="fa fa-bars"></i>查询条件</h4>
                                            </div>
                                            <div class="box-body big" style="padding:10px;">
                                                <form class="form-horizontal" role="form" id="form_contract">
                                                    <div class="form-group mrg-bt10">
                                                        <label class="col-sm-1 control-label">供应商名称：</label>
                                                        <div class="col-sm-2">
                                                            <input type="text" class="form-control" name="q"
                                                                placeholder="输入供应商名称">
                                                        </div>

                                                        <label class="col-sm-1 control-label" for="e1">合同状态：</label>
                                                        <div class="col-sm-2">
                                                            <select id="status_select" class="col-md-12 select2-offscreen"
                                                                tabindex="-1">
                                                                <option value=-1>选择状态</option>
                                                                <option value="NotArchived">未归档</option>
                                                                <option value="Archived">已归档</option>
                                                                <option value="Buying">结算中</option>
                                                                <option value="Completed">结算完成</option>
                                                                <option value="Cancel">作废</option>
                                                            </select>
                                                        </div>
                                                        <label class="col-sm-1 control-label">创建日期：</label>
                                                        <div class="col-sm-3" style="display:inline-flex">
                                                            <div class="float-left" style="width:130px">
                                                                <input type="text" name="startDate" class="form-control bootstrap-datepicker">
                                                            </div>
                                                            <div style="width: 27px;text-align: center">至</div>
                                                            <div class="float-left" style="width:130px">
                                                                <input type="text" name="endDate" class="form-control bootstrap-datepicker">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="form-group mrg-bt10">
                                                        <label class="col-sm-1 control-label">商品名称：</label>
                                                        <div class="col-sm-2">
                                                            <input type="text" class="form-control" name="productName"
                                                                placeholder="输入商品名称">
                                                        </div>
                                                        <label class="col-sm-1 control-label">合同编号：</label>
                                                        <div class="col-sm-2">
                                                            <input type="text" class="form-control" name="scontractCode"
                                                                placeholder="输入合同编号">
                                                        </div>
                                                        <label class="col-sm-1 control-label">SKU编码：</label>
                                                        <div class="col-sm-2">
                                                            <input type="text" class="form-control" name="skuCode"
                                                                placeholder="输入SKU编码">
                                                        </div>
                                                        <div class="col-sm-1">
                                                            <a class="btn btn-primary search">查询</a>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /FORMS QUERY -->
                        <div class="row" style="height: 30px;">
                            <div class="col-md-12">
                                <div class="box ">
                                    <a href="#" class="btn btn-success config addBtn">
                                        <i class="fa  fa-plus-square-o"></i> 新增合同
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <!-- TABLES -->
                            <div class="col-md-12">
                                <!-- BOX -->
                                <div class="box border primary">
                                    <div class="box-title">
                                        <h4><i class="fa fa-table"></i>合同数量：<span id="total"></span> 条</h4>

                                    </div>
                                    <div class="box-body">
                                        <table id="db_coupon_list" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover"
                                            style="word-break:break-all; word-wrap:break-word;">

                                        </table>
                                    </div>
                                </div>
                                <!-- /BOX -->
                            </div>
                        </div>
                        <!-- /TABLES -->


                        <div class="footer-tools">
                            <span class="go-top">
                                <i class="fa fa-chevron-up"></i> Top
                            </span>
                        </div>
                    </div><!-- /CONTENT-->
                </div>
            </div>
        </div>
    </section>
    <!--/PAGE -->
    <!-- JAVASCRIPTS -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- JQUERY UI-->
    <script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
    <!-- BOOTSTRAP -->
    <script src="../../bootstrap-dist/js/bootstrap.min.js"></script>

    <!-- BLOCK UI -->
    <script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>

    <!-- AUTOSIZE -->
    <script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>

    <!-- INPUT MASK -->
    <script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
    <!-- SELECT2 -->
    <script type="text/javascript" src="../../js/select2/select2.min.js"></script>

    <!-- bootstrap-fileupload -->
    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.iframe-transport.js"></script>
    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload.min.js"></script>
    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-process.min.js"></script>
    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-validate.min.js"></script>

    <!-- UNIFORM -->
    <script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
    <!-- spinner -->
    <script src="../../js/spinner/spin.js"></script>
    <!-- DATA TABLES -->
    <script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
    <script type="text/javascript" src="../../js/datatables/datatable.js"></script>
    <script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
    <script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
    <script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>

    <!--bootbox-->
    <script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
    <!-- COOKIE -->
    <script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
    <!-- CUSTOM SCRIPT -->
    <script src="../../js/script.js"></script>
    <script>
        var Coupon = function () {
            var $mainDataTable = null;
            var contractType = $.getUrlParam("contractType");

            $(".addBtn").click(function () {
                location.href = "add_contract.html?contractType=" + contractType;
            });

            var search = function () {

                var startDate = $("input[name=startDate]").val();
                var endDate = $("input[name=endDate]").val();

                var q = $("input[name=q]").val();
                var status = $("#status_select").val();

                var url = App.getContextPath() + "admin/contract/searchContract.do?contractType=" +
                    contractType + "&q=" + q;
                if (status != -1 && status != null)
                    url += "&contractStatus=" + status;

                if (startDate != "")
                    url += "&startDate=" + startDate;
                if (endDate != "")
                    url += "&endDate=" + $.dateAdd(endDate);

                url += "&productName=" + $("[name=productName]").val() + "&contractCode=" + $(
                    "[name=scontractCode]").val() + '&skuCode=' +  $("[name=skuCode]").val();
                if ($mainDataTable) {
                    $mainDataTable.api().ajax.url(url).load();
                    return;
                }
                var dtSetting = $.dataTableSetting({

                    "ajaxSource": url,
                    "serverSide": true,
                    "bFilter": false, // 去掉搜索框
                    "bLengthChange": true, // 每页显示数量
                    "sScrollX": "100%",
                    "sScrollXInner": "100%",
                    "iDisplayLength": 10,
                    "bSort": false,
                    "aoColumns": [{
                        "mDataProp": "contractCode",
                        "sTitle": "合同编号",
                        "width": "8%"

                    }, {
                        "mDataProp": "adminSupplier.supplierName",
                        "sTitle": "供应商",
                        "width": "10%",
                        "render": function (data, type, row) {
                            return "<a href='new_supply.html?id=" + row.supplierId +
                                "&flag=1'>" + data + "</a>";
                        }

                    }, {
                        "sTitle": "合同金额",
                        "mDataProp": "contractPrice",
                        "width": "8%"
                    }, {
                        "sTitle": "订货量",
                        "mDataProp": "quantity",
                        "width": "6%"
                    }, {
                        "sTitle": "结算方式",
                        "mDataProp": "settlementMode",
                        "width": "8%",
                        "render": function (data, type, row) {
                            if (row.settlementMode == "Bill") {
                                return "按进货单结算";
                            } else {
                                return "按扣点结算";
                            }
                        }
                    }, {
                        "sTitle": "结算类型",
                        "mDataProp": "settlementType",
                        "width": "8%",
                        "render": function (data, type, row) {
                            if (row.settlementType == "Mg") {
                                return "款到发货";
                            } else {
                                return "货到付款";
                            }
                        }
                    }, {
                        "sTitle": "附加协议",
                        "mDataProp": "supplementCount",
                        "width": "8%",
                        "render": function (data, type, row) {
                            return "<a href='settlement_contract.html?changeContractCode=" +
                                row.contractCode + "'>" + data + "</a>";
                        }
                    }, {
                        "sTitle": "负责人",
                        "mDataProp": "leader",
                        "width": "6%"
                    }, {
                        "sTitle": "创建时间 ",
                        "width": "8%",
                        "render": function (data, type, row) {
                            return $.getLocalDate(row.createTime);
                        }
                    }, {
                        "sTitle": "状态",
                        "mDataProp": "contractStatus",
                        "width": "6%",
                        "render": function (data, type, row) {
                            if (row.contractStatus == 'NotArchived') {
                                return "未归档";
                            } else if (row.contractStatus == 'Archived') {
                                return "已归档";
                            } else if (row.contractStatus == 'Buying') {
                                return "结算中";
                            } else if (row.contractStatus == 'Completed') {
                                return "已完成";
                            } else {
                                return "作废";
                            }

                        }
                    }, {
                        "sTitle": "操作",
                        "width": "12%",
                        "render": function (data, type, row) {


                            var str = "";
                            str +=
                                "<a class='btn btn-success btn-xs btn-width' style='width:60px;' href='add_contract.html?opType=view&id=" +
                                row.id + "'><i class='fa fa-arrow-circle-o-up'></i>查看</a>";
                            if (row.contractStatus != 'Cancel') {
                                str +=
                                    "<a class='btn btn-warning btn-xs btn-width remarkBtn' style='width:60px' href='javascript:void(0)' content='" +
                                    row.remark + "' contractId='" + row.id + "'></i>备注</a>";
                            }

                            if (row.contractStatus == 'NotArchived') {
                                str +=
                                    "<a class='btn btn-primary btn-xs btn-width editBtn' style='width:60px' href='add_contract.html?opType=edit&id=" +
                                    row.id +
                                    "'><i class='fa fa-arrow-circle-o-up'></i>修改</a>";

                                if (App.checkButton("Contract:Archived")) {
                                    str +=
                                        "<a class='btn btn-success btn-xs btn-width   archivedBtn' style='width:60px;' href='javascript:void(0)' contractId='" +
                                        row.id + "' contractCode='" + row.contractCode +
                                        "'></i>归档</a>";
                                }
                                str +=
                                    "<a class='btn btn-danger btn-xs btn-width delBtn' style='width:60px' href='javascript:void(0)' contractId='" +
                                    row.id +
                                    "'><i class='fa fa-arrow-circle-o-up'></i>删除</a>";
                            }

                            if (row.contractStatus == 'Archived') {

                                if (App.checkButton("Contract:Cancel")) {
                                    str +=
                                        "<a class='btn btn-danger btn-xs btn-width cancelBtn' style='width:60px ;' href='javascript:void(0)' contractId='" +
                                        row.id + "'></i>作废</a>";
                                }
                                if (row.isUpload) {
                                    str +=
                                        "<a class='btn btn-warning btn-xs btn-width download' style='width:60px ;' contractCode=" +
                                        row.contractCode +
                                        " href='javascript:void(0)' ></i>下载<form id=" + row
                                        .contractCode +
                                        " action='../../admin/contract/downloadContract.do?contractCode=" +
                                        row.contractCode +
                                        "&fileType=Contract'></form></a>";

                                } else {
                                    str +=
                                        "<a class='btn btn-warning btn-xs btn-width upload' style='width:60px ;' href='javascript:void(0)' contractCode='" +
                                        row.contractCode + "' id='" + row.id +
                                        "'></i>上传</a>";
                                }
                            }
                            if (row.contractStatus == 'Archived' || row.contractStatus ==
                                'Buying') {
                                str +=
                                    "<a class='btn btn-success btn-xs btn-width changeBtn' style='width:60px;' href='add_settlement_contract.html?changeContractCode=" +
                                    row.contractCode + "&contractId=" + row.id +
                                    "'><i class='fa fa-arrow-circle-o-up'></i>变更</a>";
                            }
                            str +=
                                "<a class='btn btn-default btn-xs btn-width bt-print' style='width:60px' href='javascript:void(0)' id='" +
                                row.id + "' >打印<form id='" + row.id +
                                "' action='../../admin/contract/printContract.do'></form></a>";



                            return str;
                        }
                    }]
                });

                $mainDataTable = $("#db_coupon_list").dataTable(dtSetting);
            };
            var contractCode = "";
            var id = "";
            var fileUpLoad = function () {

                $(".progress").hide();
                $("[upload-file=imageUrlProduct]").fileupload({
                    url: App.getContextPath() + "admin/contract/upLoadContract.do",
                    formData: {
                        fileType: "Contract",
                        contractCode: contractCode,
                        id: id
                    },
                    dataType: 'json',
                    acceptFileTypes: /(\.|\/)(pdf)$/i,
                    iframe: true,
                    start: function (e) {
                        $('.progress').fadeIn(300);
                        return true;
                    },
                    autoUpload: true,
                    done: function (e, data) {
                        $("#box-config").modal("hide");
                        $.alert("上传成功");
                        search();

                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('.progress .progress-bar').css('width', progress + '%');
                    }
                }).on('fileuploaddone', function (e, data) {
                    $(".progress").fadeOut(300);

                });

            };

            var checkButton = function () {

            }
            return {
                init: function () {
                    $.initDate($("#form_contract"), -180, 0);
                    $("#status_select").select2({
                        placeholder: "选择状态"
                    });
                    checkButton();
                    $(".search").click(search);
                    search();
                    //删除
                    $("body").on("click", ".delBtn", function () {
                        var _this = $(this);
                        $.confirm("确定要删除吗?", function () {

                            $.ajax({
                                type: "get",
                                url: App.getContextPath() +
                                    "admin/contract/deleteContract.do?id=" + _this.attr(
                                        "contractId"),
                                success: function (data) {

                                    if (data.type == "error") {
                                        $.alert(data.extra);
                                    } else {
                                        search();
                                    }
                                }
                            });


                        });
                    })

                    //归档
                    $("body").on("click", ".archivedBtn", function () {
                        var _this = $(this);
                        $("#archivedBox").modal("show");
                        $("#archivedBox").find("[name=id]").val(_this.attr("contractId"));
                        $("#archivedBox").find("[name=contractCode]").val(_this.attr("contractCode"));
                        // $("#archivedBox").find("[name=contractCode]").attr("readonly","readonly");
                    })

                    $("#archivedBox .bt-save").click(function () {
                        var id = $("#archivedBox").find("[name=id]").val();
                        var code = $("#archivedBox").find("[name=contractCode]").val();
                        if (code == "") {
                            $.alert("请输入合同编号");
                            return;
                        }
                        $.ajax({
                            type: "get",
                            url: App.getContextPath() +
                                "admin/contract/archivedContract.do?id=" + id +
                                "&contractCode=" + code,
                            success: function (data) {

                                $("#archivedBox").modal("hide");
                                $("#archivedBox").find("input").val("");
                                $("#archivedBox").find("textarea").val("");
                                if (data.type == "error") {
                                    $.alert(data.extra);
                                } else {

                                    search();
                                }
                            }
                        });
                    });

                    $("body").on("click", ".remarkBtn", function () {
                        var _this = $(this);
                        $("#remarkBox").modal("show");
                        $("#remarkBox").find("[name=id]").val(_this.attr("contractId"));

                        $(" [name=remark]").val($(this).attr("content"));

                    })
                    $("#remarkBox .bt-save").click(function () {
                        var id = $("#remarkBox").find("[name=id]").val();
                        var remark = encodeURI($("#remarkBox").find("[name=remark]").val());
                        console.log(remark);
                        $.ajax({
                            type: "get",
                            url: App.getContextPath() + "admin/contract/updateRemark.do?id=" +
                                id + "&remark=" + remark,
                            success: function (data) {
                                $("#remarkBox").modal("hide");
                                $("#remarkBox").find("input").val("");
                                $("#remarkBox").find("textarea").val("");
                                search();
                            }
                        });
                    });


                    $("body").on("click", ".cancelBtn", function () {
                        var _this = $(this);
                        $("#cancelBox").modal("show");
                        $("#cancelBox").find("[name=id]").val(_this.attr("contractId"));

                    })
                    $("#cancelBox .bt-save").click(function () {
                        var id = $("#cancelBox").find("[name=id]").val();
                        var cancelReason = $("#cancelBox").find("[name=cancelReason]").val();
                        $.ajax({
                            type: "get",
                            url: App.getContextPath() + "admin/contract/cancelContract.do?id=" +
                                id + "&cancelReason=" + cancelReason,
                            success: function (data) {
                                $("#cancelBox").modal("hide");
                                $("#cancelBox").find("input").val("");
                                $("#cancelBox").find("textarea").val("");
                                search();
                            }
                        });
                    });
                    //上传
                    $("body").on("click", ".upload", function () {
                        contractCode = $(this).attr("contractcode");
                        id = $(this).attr("id");
                        fileUpLoad();
                        $("#box-config").find("[name=id]").val(id);
                        $("#box-config").find(".contractCode").html(contractCode);
                        $("#box-config").modal("show");

                    })
                    //下载
                    $("body").on("click", ".download", function () {
                        contractCode = $(this).attr("contractcode");
                        $(this).find("form").append("<input type='hidden' name=contractCode value='" +
                            contractCode + "'/>")
                        $(this).find("form").append(
                            "<input type='hidden' name=fileType value='Contract'/>")
                        $(this).find("form").submit();



                    })
                    //打印
                    $("body").on("click", ".bt-print", function () {
                        var id = $(this).attr("id");

                        $(this).find("form").append("<input type='hidden' name=id value='" + id + "'/>")

                        $(this).find("form").submit();



                    })

                }
            }
        }();

        $(function () {
            $("#header").load("../head.html");
            App.init(); //Initialise plugins and elements
            Coupon.init();

        });
    </script>
    <!-- /JAVASCRIPTS -->
</body>

</html>